<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
//    1.用于创建对象
const o1 = Object.create(null,{
    name:{
        value:'kobe',
        writable:true,
        enumerable:true,
        configurable:true
    }
})

let value = 18
const o2 = Object.create(null,{
    age:{
        get(){
            return value
        },
        set(val){
            value = val
        }
    }
})

//2.用于创建一个对象，将生成对象的原型指向第一个参数
// Object.create(null)常用与创建一个空对象，这样是为了防止Object的原型修改时对新建的对象产生影响
const obj = {
    name:'zhangSan',
    age:20,
    play(){
        console.log('play')
    }
}

const o3 = Object.create(obj,{
    sex:{
        value:'男',
        writable:true,
        enumerable:true,
        configurable:true
    }
})
console.log(o3)

//3.手动实现Object.create方法
function MyCreate(obj){
    function F(){}
    F.prototype = obj
    return new F()
}
const o4 = MyCreate(obj)
console.log(o4)
</script>
</body>
</html>